(deftemplate number(slot parteintreaga)(slot partezecimala))
(deftemplate suma(slot parteintreaga)(slot partezecimala))

(assert(suma(parteintreaga 0)(partezecimala 0)))

(assert(number(parteintreaga 1)(partezecimala 0)))
(assert(number(parteintreaga 4)(partezecimala 7)))
(assert(number(parteintreaga 1)(partezecimala 5)))
(assert(number(parteintreaga 15)(partezecimala 0)))
(assert(number(parteintreaga 2)(partezecimala 56)))
(assert(number(parteintreaga 19)(partezecimala 5)))

(defrule printare
   (number(parteintreaga ?i)(partezecimala ?z))
    =>
    (printout t " Numarul are partea intreaga " ?i " si partea zecimala " ?z crlf)
    )
; crlf trece pe rand nou

(facts)
(defrule adunaintreg
    ?idnumber<-(number(parteintreaga ?i))
    ?idfapt<-(suma(parteintreaga ?s))
    =>
    (bind ?s1 (+ ?s ?i))
    (modify ?idfapt(parteintreaga ?s1))
    (retract ?idnumber)
    )
(run)
(facts)
(defrule print
    (suma(parteintreaga ?s))
    =>
    (printout t "Suma este: " ?s)
    )

;(defrule adunazecimale
 ;   ?idnumber<-(number(partezecimala ?z))
  ;  ?idfapt<-(suma(partezecimala ?s))
   ; =>
    ;(bind ?s1 (+ ?s ?i))
    ;(modify ?idfapt(parteintreaga ?s1))
    ;(printout t "Suma este: " ?s1 crlf)
    ;(retract ?idnumber)
    ;)

(run)
(facts)